package com.cgy.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.cgy.service.RabbitMqService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * FaceEvenCallbackController
 *
 * @author guoxin
 * @since 2024/1/9 0009 14:20
 */
@Slf4j
@RestController
public class FaceEvenCallbackController {

    @Autowired
    private RabbitMqService rabbitMqService;

    @PostMapping("/event/RcV")
    public String callback(@RequestBody String data) {
        log.info("FaceEvenCallbackController callback param {}", JSON.toJSON(data));

        rabbitMqService.process(data);

        JSONObject jsonBody = new JSONObject();
        jsonBody.put("code", "0");
        jsonBody.put("msg", "success");
        jsonBody.put("data", null);

        return jsonBody.toJSONString();
    }

}
